﻿using BySoft.Server.Business;
using BySoft.Server.Common;
using BySoft.Server.Common.Entity;
using BySoft.Web.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BySoft.Web.Site.MasteData
{
    public partial class ExchangeRateView : AuthBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindDDL();
                BindData();
            }
        }

        private void BindDDL()
        {
            BindParameterForListControl("Currency", ddlCurrency);
            UIHelper.InsertFirstItem(ddlCurrency);
        }

        private void BindData()
        {
            string strCode = HttpUtility.UrlDecode(UIHelper.GetQueryStringValue("id").Trim());
            if (!string.IsNullOrEmpty(strCode))
            {
                MdExchangerateEntity en = MdExchangerate.GetMdExchangerateByID(CommonMethod.ConvertToInt(strCode));
                if (en != null)
                {
                    this.lblExchangeDate.Text = string.Format("{0:yyyy-MM-dd}", en.ExchangeDate);
                    this.lblExchangeRate.Text = en.ExchangeRate.ToString();
                    this.ddlCurrency.SelectedValue = en.Currency.Trim();
                }
            }
        }
    }
}